<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php $this->load->view('common/head'); ?>

<?php $this->load->view('common/header'); ?>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar'); ?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs'); ?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set'); ?>
                <div class="page-header">
                    <h1>
                        定向推送
                        <small>
                            <i class="ace-icon fa fa-angle-double-right"></i>
                            定向推送，请选择接收人
                        </small>
                    </h1>
                </div>
                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" action="<?php echo site_url(X_URL . 'OrderCar/push_order_user'); ?>"
                              method="post">
                            <?php echo csrf_hidden(); ?>
                            <input type="hidden" name="order_id" value="<?php if (!empty($get['order_id'])) {echo $get['order_id'];} ?>">
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-6"> 选择用户 </label>
                                <div class="col-sm-6">
                                    <select id="user_id" name="user_id" class="col-xs-10 col-sm-10 select2">
                                        <option value="">可选择</option>
                                        <?php if (isset($users)) { ?>
                                            <?php foreach ($users as $key => $val) { ?>
                                                <option value="<?php echo $val['user_id']; ?>"><?php echo $val['user_name']; ?></option>
                                            <?php } ?>
                                        <?php } ?>
                                    </select>
                                </div>
                            </div>

                            <br>
                            <div class="col-md-offset-2 col-md-9">
                                <button class="btn btn-info" type="submit">
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    </div><?php $this->load->view('common/footer'); ?>


<?php $this->load->view('common/footerjs'); ?>
<!-- inline scripts related to this page -->
<?php echo admin_js_url('laydate'); ?>
<script>
    var service_url = "<?php echo site_url('manage/CarService/get_service');?>";
    var area_url = "<?php echo site_url('manage/Area/get_area');?>";
    laydate.render({
        elem: '#start_time' //指定元素
        , type: "datetime"
    });
    $(function () {
        $(".select2").select2();
        var order_service_select2 = $("#order_service_id").select2();
        var departure_city_select2 = $("#departure_city").select2();
        var destination_city_select2 = $("#destination_city").select2();

        $("#order_type").on("select2:select", function (e) {
            console.log($(this).val());
            var p_id = $(this).val();
            if (p_id > 0) {
                $.ajax({
                    method: "GET",
                    url: service_url,
                    data: {p_id: p_id}
                }).done(function (data) {
                    // console.log(data);
                    $("#order_service_id").html(data);
                    order_service_select2.val(0).trigger("change");
                })
            } else {
                $("#order_service_id").html('<option selected="selected" value="0">可选择</option>');
                order_service_select2.val(0).trigger("change");
            }
        });
        $("#departure_country").on("select2:select", function (e) {
            console.log($(this).val());
            var p_id = $(this).val();
            if (p_id > 0) {
                $.ajax({
                    method: "GET",
                    url: area_url,
                    data: {p_id: p_id}
                }).done(function (data) {
                    // console.log(data);
                    $("#departure_city").html(data);
                    departure_city_select2.val(0).trigger("change");
                })
            } else {
                $("#departure_city").html('<option selected="selected" value="0">可选择</option>');
                departure_city_select2.val(0).trigger("change");
            }
        });
        $("#destination_country").on("select2:select", function (e) {
            console.log($(this).val());
            var p_id = $(this).val();
            if (p_id > 0) {
                $.ajax({
                    method: "GET",
                    url: area_url,
                    data: {p_id: p_id}
                }).done(function (data) {
                    // console.log(data);
                    $("#destination_city").html(data);
                    destination_city_select2.val(0).trigger("change");
                })
            } else {
                $("#destination_city").html('<option selected="selected" value="0">可选择</option>');
                destination_city_select2.val(0).trigger("change");
            }
        });
    });
</script>
</body>
</html>



